package ListMethod

object ListTest {
  def main(args: Array[String]): Unit = {

    val arr = Array(1, 7, 3, 6, 2, 4, 8, 5, 4, 9)
    val max = arr.max
    println(max)
    val min = arr.min
    val sum = arr.sum
    println(sum)


    /**
     * 1 + 7 = 8
     * 8 + 3 = 11
     * 11 + 6 = 17
     * ...
     */
    val r = arr.reduce((x, y) => x + y)
    val r1 = arr.reduceLeft((x, y) => x + y)
    var r2 = arr.reduce(_ + _)

    // 100 + 1 = 101
    // 101 + 7 = 108
    // 108 + 3 = 111
    // ...
    val r3 = arr.fold(100)(_ + _)
    val r4 = arr.foldLeft(100)(_ + _)
    println(r)

  }

}
